package com.example.superoa.common;
import java.io.IOException;
import java.util.Set;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class MyFunctionTag extends SimpleTagSupport{
	//在页面使用循环功能列表中的id，传递到该变量中
	private int funId;

	public int getFunId() {
		return funId;
	}
	
	public void setFunId(int funId) {
		this.funId = funId;
	}

	@Override
	public void doTag() throws JspException, IOException {
		HttpSession session = 
				((PageContext)this.getJspContext()).getSession();
		//从session中获取用户的功能id列表
		Set<Integer> funsId =
				(Set<Integer>) session.getAttribute("funsId");
		//循环与所有功能列表中的id进行判断
		for (Integer id : funsId) {
			if(id == funId) {
				//原样输出
				this.getJspBody().invoke(null);
			}
		}
	}
	}
